import { customerApi } from './api'
import axios from 'axios'

export default {
  addOne(customer) {
    return axios({
      method: 'post',
      url: customerApi.addOneUrl(),
      data: customer,
      withCredentials: true
    })
  },
  updateOne(customerId,customer) {
    return axios({
      method: 'put',
      url: customerApi.updateOneUrl(customerId),
      data: customer,
      withCredentials: true
    })
  },
  getOne(customerId) {
    return axios({
      method: 'get',
      url: customerApi.getOneUrl(customerId),
      withCredentials: true
    })
  },
  getList(params) {
    return axios({
      method: 'get',
      url: customerApi.getListUrl(params),
      withCredentials: true
    })
  },
  deleteOne(customerId) {
    return axios({
      method: 'delete',
      url: customerApi.deleteOneUrl(customerId),
      withCredentials: true
    })
  },
  changePassword(customerId, newPassword) {
    let url = customerApi.changePasswordUrl(customerId) +'?newPassword=' + newPassword
    return axios({
      method: 'put',
      url: url,
      withCredentials: true
    })
  }
}
